import requests
import time
from bs4 import BeautifulSoup
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'  #伪装成浏览器
}
url = 'https://movie.douban.com/chart'
r = requests.get(url, headers=headers)
r.encoding="UTF-8"
soup = BeautifulSoup(r.text, 'html.parser')
# 图片
alst = soup.find_all('img')
# 演员
jian = soup.find_all('p')
# 评价
span = soup.find_all('span')

list4 = {}
for a in alst:
    if a.get('alt') != None and a.get('alt')[:2] != '扫码':
        list4[a.get('alt')] = a.get('src')
print(list4)

# 演员
list3 = {}
for i in jian:
    if i.string != None and i.string[:4] == '2022':
        print(i.string)

# 评价
list2 = {}
for i in span:
    if i.string != None and i.string[:1] == '(':
        print(i.string)


# 评分
ping = soup.find_all('span')
list1 = {}
for i in ping:
    if i.string != None and '.' in i.string and i.string[7:10] != '200':
            print(i.string)


